<template>
    <div>
        <!-- 面包屑导航 -->
        <el-bread></el-bread>
        <!-- 添加按钮 -->
        <el-button @click="addDialog" plain class="btn" type="primary" size="small">添加</el-button>
        <!-- 列表 -->
        <v-list @edit="edit"></v-list>
        <!-- 弹框 -->
        <v-dialog ref='diaInfo' :isshow="isshow" :isAdd="isAdd" @cancel="cencel"></v-dialog>
    </div>
</template>

<script>
import vList from './list.vue'
import vDialog from './dialog.vue'
export default {
    data() {
        return {
            isshow: false,  //用于判断弹框是否显示
            isAdd: true  //用于判断是新增还是编辑
        };
    },
    components: {
        vList,
        vDialog
    },
    methods: {
        addDialog() {
            //打开弹框
            this.isshow = true
            // 告诉弹框是新增
            this.isAdd = true
        },
        cencel(e) {
            this.isshow = e
        },
        // 编辑
        edit(e) {
            //打开弹框
            this.isshow = true
            //告诉弹框你是编辑
            this.isAdd = false
            //给子组件中的函数方法赋值
            this.$refs.diaInfo.lookup(e)
        }
    }
};
</script>

<style scoped>
.btn {
    margin: 10px 5px;
}
</style>
